package com.rui.study.algorithm.P_单链表反转;

import com.rui.study.algorithm.ListNode;

/**
 * @program: study
 * @description:
 * @author: Yaowr
 * @create: 2019-03-08 07:56
 **/
public class Solution_4 {

    public ListNode reverseList(ListNode head) {
        ListNode pre = null;
        ListNode next;
        while (head != null) {
            next = head.next;
            head.next = pre;
            pre = head;
            head = next;
        }
        return pre;
    }
}
